import request from "@/utils/request";
import { ParamsType, AuditForm } from "@/api/system/corps/types";
import { CorpForm } from "@/api/account/corp/types";
import { encryptSM3 } from "@/utils/gmcrypto";

/**
 * 企业库列表
 * @param pages
 */
export function getCorpsList(pages: ParamsType) {
  return request({
    url: "api/v1/sysuser/Corp/page",
    method: "get",
    params: pages,
  });
}

/**
 * 企业库详情
 */
export function getCorpsInfo(id: number) {
  return request({
    url: `api/v1/sysuser/Corp/${id}/form`,
    method: "get",
  });
}

//修改企业信息
export function updateCorp(id: number, data: CorpForm) {
  return request({
    url: "/api/v1/sysuser/Corp/" + id,
    method: "put",
    data: data,
  });
}

//删除企业信息
export function deleteCorp(id: number) {
  return request({
    url: "/api/v1/sysuser/Corp/" + id,
    method: "delete",
  });
}

/**
 * 重置密码
 * @param id
 */
export function ResetPassword(id: number, password: string) {
  return request({
    url: "/api/v1/sysuser/Corp/resetPassword/" + id,
    method: "put",
    params: {
      password: encryptSM3(password),
    },
  });
}

/**
 * 审核企业
 * @param id
 * @param auditForm
 * @returns
 */
export function AuditCorp(id: number, auditForm: AuditForm) {
  return request({
    url: "/api/v1/sysuser/Corp/" + id + "/audit",
    method: "put",
    data: auditForm,
  });
}
